﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

namespace insurance.application
{
    /// <summary>
    /// Summary description for ApplyMain
    /// </summary>
    public class ApplyMainBLL
    {
        public ApplyMainBLL()
        {

        }
        public int ApplicationId { set; get; }
        public String CustId { set; get; }
        public String ApplicationSatus { set; get; }
        public String AccountNo { set; get; }
        public DateTime? ApplicationDate { set; get; }
        public DateTime? StartDate { set; get; }
        public DateTime? EndDate { set; get; }
        public String PaymentWay { set; get; }
        public DateTime? ApprovalDate { set; get; }
        public String StaffId { set; get; }
        public String SavingAccountNo { set; get; }
        public String ApplyCategory { set; get; }
        public String ApplyProduct { set; get; }
        public String ProductType { set; get; }
        public LinkedList<ApplyInsuredBLL> Insureds = new LinkedList<ApplyInsuredBLL>();


        public void ApplyInsurance()
        {

            ApplyMainDAL dal = new ApplyMainDAL();

            LinkedList<ApplyInsuredDAL> InsuredsDal = new LinkedList<ApplyInsuredDAL>();
            foreach (ApplyInsuredBLL insured in Insureds)
                {
                    ApplyInsuredDAL insuredDal = new ApplyInsuredDAL();
                    insuredDal.Nric=insured.Nric;
                    insuredDal.ApplicationId=insured.ApplicationId;
                    insuredDal.FirstName=insured.FirstName;
                    insuredDal.LastName=insured.LastName;
                    insuredDal.Nationality=insured.Nationality;
                    insuredDal.IsMale=insured.IsMale;
                    insuredDal.StartDate=insured.StartDate;
                    insuredDal.EndDate = insured.EndDate;
                    insuredDal.MaritalStatus=insured.MaritalStatus;
                    insuredDal.Dob=insured.Dob;
                    insuredDal.Relationship=insured.Relationship;
                    insuredDal.Plan=insured.Plan;
                    insuredDal.Occupation=insured.Occupation;
                    insuredDal.Tel=insured.Tel;
                    insuredDal.LongStay=insured.LongStay;
                    insuredDal.Mobile=insured.Mobile;
                    insuredDal.Email=insured.Email;
                    insuredDal.MailingAddress=insured.MailingAddress;
                    insuredDal.Postal=insured.Postal;
                    insuredDal.Employer=insured.Employer;
                    insuredDal.CompanyAddress=insured.CompanyAddress;
                    insuredDal.Business=insured.Business;
                    insuredDal.NatureOfIllness=insured.NatureOfIllness;
                    insuredDal.NatureDate=insured.NatureDate;
                    insuredDal.ResultOfTreatment=insured.ResultOfTreatment;
                    insuredDal.NatureHospital=insured.NatureHospital;
                    insuredDal.ForeseeableIllness=insured.ForeseeableIllness;
                    insuredDal.HyperlipidaemiaReading=insured.HyperlipidaemiaReading;
                    insuredDal.HyperlipidaemiaDate=insured.HyperlipidaemiaDate;
                    insuredDal.HyperlipidaemiaHospital=insured.HyperlipidaemiaHospital;
                    insuredDal.HighCholesterolLevel=insured.HighCholesterolLevel;
                    insuredDal.HighCholesterolDate=insured.HighCholesterolDate;
                    insuredDal.HighCholesterolHospital=insured.HighCholesterolHospital;
                    insuredDal.Height=insured.Height;
                    insuredDal.Weight=insured.Weight;
                    insuredDal.IsSmoker=insured.IsSmoker;
                    insuredDal.Hazardous=insured.Hazardous;
                    insuredDal.TravelFrequency=insured.TravelFrequency;
                    insuredDal.DeclinedHistory=insured.DeclinedHistory;
                    insuredDal.docPath = insured.docPath;
                    InsuredsDal.AddLast(insuredDal);

                }



            dal.ApplyInsurance(
                 this.ApplicationId,
                 this.CustId,
                  this.ApplicationSatus,
                    this.AccountNo,
                    this.ApplicationDate,
                    this.StartDate,
                    this.EndDate,
                    this.PaymentWay,
                    this.ApprovalDate,
                    this.StaffId,
                    this.SavingAccountNo,
                    this.ApplyCategory,
                    this.ApplyProduct,
                    this.ProductType,
                    InsuredsDal
                );
        }
    }
}